<!doctype HTML public "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- Click to Convert 5.2: Anything to HTML -->
<!-- http://www.clicktoconvert.com -->

<html>
<head>
<title>gravityboxscheduleuserguide - page 61 of 234</title>
<meta http-equiv=content-type content=text/html;charset=iso-8859-1>
<meta name="Generator" content="Click to Convert">

<!--Start of page styles-->
<STYLE TYPE="text/css">
<!--
 /* Foreground Image Styles */

 /* Position Styles */
 .ts61p0{position:absolute;left:106px;top:97px;}
 .ts61p1{position:absolute;left:352px;top:97px;}
 .ts61p3{position:absolute;left:672px;top:97px;}
 .ts61p7{position:absolute;left:106px;top:113px;}
 .ts61p8{position:absolute;left:706px;top:1026px;}
 .ts61p9{position:absolute;left:331px;top:1044px;}
 .ts61p13{position:absolute;left:106px;top:147px;}
 .ts61p15{position:absolute;left:106px;top:165px;}
 .ts61p18{position:absolute;left:106px;top:183px;}
 .ts61p19{position:absolute;left:106px;top:201px;}
 .ts61p21{position:absolute;left:106px;top:220px;}
 .ts61p23{position:absolute;left:106px;top:238px;}
 .ts61p25{position:absolute;left:106px;top:256px;}
 .ts61p27{position:absolute;left:106px;top:274px;}
 .ts61p28{position:absolute;left:106px;top:292px;}
 .ts61p30{position:absolute;left:106px;top:310px;}
 .ts61p32{position:absolute;left:106px;top:328px;}
 .ts61p33{position:absolute;left:106px;top:346px;}
 .ts61p35{position:absolute;left:106px;top:365px;}
 .ts61p36{position:absolute;left:106px;top:383px;}
 .ts61p38{position:absolute;left:106px;top:420px;}
 .ts61p40{position:absolute;left:106px;top:438px;}
 .ts61p41{position:absolute;left:106px;top:457px;}
 .ts61p42{position:absolute;left:106px;top:475px;}
 .ts61p44{position:absolute;left:106px;top:494px;}
 .ts61p46{position:absolute;left:106px;top:512px;}
 .ts61p47{position:absolute;left:106px;top:530px;}
 .ts61p48{position:absolute;left:106px;top:549px;}
 .ts61p49{position:absolute;left:106px;top:567px;}
 .ts61p51{position:absolute;left:106px;top:586px;}
 .ts61p52{position:absolute;left:106px;top:604px;}
 .ts61p53{position:absolute;left:106px;top:622px;}
 .ts61p55{position:absolute;left:106px;top:641px;}
 .ts61p56{position:absolute;left:106px;top:659px;}
 .ts61p57{position:absolute;left:106px;top:678px;}
 .ts61p59{position:absolute;left:106px;top:696px;}
 .ts61p60{position:absolute;left:106px;top:714px;}
 .ts61p61{position:absolute;left:106px;top:733px;}
 .ts61p63{position:absolute;left:106px;top:751px;}
 .ts61p64{position:absolute;left:106px;top:770px;}
 .ts61p65{position:absolute;left:106px;top:788px;}
 .ts61p67{position:absolute;left:106px;top:806px;}
 .ts61p68{position:absolute;left:106px;top:825px;}
 .ts61p69{position:absolute;left:106px;top:843px;}
 .ts61p72{position:absolute;left:106px;top:862px;}
 .ts61p73{position:absolute;left:106px;top:881px;}
 .ts61p75{position:absolute;left:106px;top:899px;}
 .ts61p76{position:absolute;left:106px;top:917px;}
 .ts61p78{position:absolute;left:106px;top:935px;}
 .ts61p79{position:absolute;left:106px;top:953px;}
 .ts61p81{position:absolute;left:106px;top:972px;}
 .ts61p83{position:absolute;left:106px;top:990px;}

 /* Font Styles */
 .ft0p61{font-style:normal;font-weight:bold;font-size:13px;font-family:arial,sans-serif;color:#000000;}
 .ft1p61{font-weight:normal;}
 .ft2p61{font-style:normal;font-weight:normal;font-size:13px;font-family:"times new roman","times new roman",times,serif;color:#000000;}
 .ft3p61{font-style:normal;font-weight:normal;font-size:16px;font-family:"times new roman","times new roman",times,serif;color:#000000;}
 .ft4p61{font-style:normal;font-weight:bold;font-size:11px;font-family:arial,sans-serif;color:#000000;}
 .ft5p61{font-style:normal;font-weight:normal;font-size:16px;font-family:"courier new",courier,monospace;color:#000000;}
 .ft6p61{font-family:arial,sans-serif;}
 .ft7p61{font-style:normal;font-weight:normal;font-size:16px;font-family:arial,sans-serif;color:#000000;}
 .ft8p61{font-style:normal;font-weight:bold;font-size:21px;font-family:arial,sans-serif;color:#808080;}

 /* Background Style */
 .styleBackground61{position:absolute;left:97px;top:145px}

 /* Navigation Styles */
 .styleNavBarTop{position:absolute;left:0px;top:2px}
 .nb{position:absolute;left:2px;top:0px}
 .nbs{position:absolute;left:0px;top:0px}
 .nbe{position:absolute;left:836px;top:0px}
 .styleNavBarBot{position:absolute;left:0px;top:1117px}
-->
</STYLE>
<!--End of page styles-->

</head>
<body bgcolor="#ffffff" text="#000000" link="#0000FF" Vlink="#660099">

<table id="pageTable" width="836" STYLE="position: relative; left: auto; top: auto;"><tr><td>
<div class=nbs><img src="./navbarstart.gif" width="2" height="30"></div>
<div class=nb><img src="./navbar.gif" width="836" height="30" alt="Navigation bar"></div>
<div class=nbe><img src="./navbarend.gif" width="2" height="30"></div>
<div class=styleNavBarTop>
<table width="834" height="26" border="0" cellspacing="0">
  <tr align="left">
    <td width="4">&nbsp;</td>
    <td width="25" align="center"><a href="http://www.gravitybox.com" target="_parent"><img src="./home.gif" border="0" alt="Home"></a></td>
    <td width="25" align="center"><a href="#" onClick="window.open('./print.html','Printing','width=300,height=100,toolbar=no,directories=no');return false;"><img src="./print.gif" border="0" alt="Print document"></a></td>
    <td width="10" align="center"><img src="./separator.gif" border="0"></td>
    <td width="18" align="center"><a href="./index1.html"><img src="./start.gif" width="18" height="14" border="0" alt="Start"></a></td>
    <td width="18" align="center"><a href="./index60.html"><img src="./back.gif" width="14" height="14" border="0" alt="Previous page"></a></td>
    <td width="80" valign="middle"><table width="100%" height="16" border="0" cellspacing="1" bgcolor="#ACA899"><tr><td align="center" bgcolor="#ffffff"><font face=verdana,arial,sans-serif><font size="1">&nbsp;61 of 234&nbsp;</font></font></td></tr></table></td>
    <td width="18" align="center"><a href="./index62.html"><img src="./forward.gif" width="14" height="14" border="0" alt="Next page"></a></td>
    <td width="18" align="center"><a href="./index234.html"><img src="./end.gif" width="18" height="14" border="0" alt="End"></a></td>
    <td width="620">&nbsp;</td>
  </tr>
</table>
<p>
</div>
<nobr>
<div class=styleBackground61><img src="./background61.png" width="633" height="910" border="0" alt=""></div>
<div class=ts61p0><span class="ft0p61"> </span></div>
<div class=ts61p1><span class="ft0p61">Gravitybox Schedule Primer<span class="ft1p61"> </span></span></div>
<div class=ts61p3><span class="ft0p61">Page 59&nbsp; </span></div>
<div class=ts61p7><span class="ft2p61"> </span></div>
<div class=ts61p8><span class="ft3p61"> </span></div>
<div class=ts61p9><span class="ft4p61">1998&#45;2004 Gravitybox Software LLC<span class="ft3p61"> </span></span></div>
<div class=ts61p13><span class="ft5p61">&nbsp; Call Me.Schedule1.Categories.Clear </span></div>
<div class=ts61p15><span class="ft5p61">&nbsp; While Not rs.EOF </span></div>
<div class=ts61p18><span class="ft5p61">&nbsp;&nbsp;&nbsp; Set objCategory = Me.Schedule1.Categories.Add(rs!Name, </span></div>
<div class=ts61p19><span class="ft5p61">rs!Color) </span></div>
<div class=ts61p21><span class="ft5p61">&nbsp;&nbsp;&nbsp; objCategory.Id = rs!CategoryId </span></div>
<div class=ts61p23><span class="ft5p61">&nbsp;&nbsp;&nbsp; Call rs.MoveNext </span></div>
<div class=ts61p25><span class="ft5p61">&nbsp; Wend </span></div>
<div class=ts61p27><span class="ft5p61"> </span></div>
<div class=ts61p28><span class="ft5p61">&nbsp; Set Db = Nothing </span></div>
<div class=ts61p30><span class="ft5p61">&nbsp; Set rs = Nothing </span></div>
<div class=ts61p32><span class="ft5p61"> </span></div>
<div class=ts61p33><span class="ft5p61">End Sub<span class="ft6p61"> </span></span></div>
<div class=ts61p35><span class="ft7p61"> </span></div>
<div class=ts61p36><span class="ft8p61">Saving Appointments </span></div>
<div class=ts61p38><span class="ft7p61">Now that we have addressed loading, we need to think about how to get all of that </span></div>
<div class=ts61p40><span class="ft7p61">information into the database in the first place. The saving routines should not be very </span></div>
<div class=ts61p41><span class="ft7p61">difficult to understand after viewing the loading routines. The save method will remove </span></div>
<div class=ts61p42><span class="ft7p61">the appointments for the specified date and save the ones on the schedule as that </span></div>
<div class=ts61p44><span class="ft7p61">date&#146;s new appointments. </span></div>
<div class=ts61p46><span class="ft7p61"> </span></div>
<div class=ts61p47><span class="ft7p61">This is not a perfect scheme. Some will disagree with removing appointments that have </span></div>
<div class=ts61p48><span class="ft7p61">not changed only to read them. This is a valid point but the code was written this way for </span></div>
<div class=ts61p49><span class="ft7p61">a few reasons. First this is an example of how to save to a database, not a tutorial on </span></div>
<div class=ts61p51><span class="ft7p61">algorithm perfection. This said, I agree that examples should teach the &#147;correct&#148; way to </span></div>
<div class=ts61p52><span class="ft7p61">build code and this is a perfectly valid way to build it. There is a more important reason </span></div>
<div class=ts61p53><span class="ft7p61">that we are removing all appointments first; appointment moves. Posit, in an MDI </span></div>
<div class=ts61p55><span class="ft7p61">environment, the user may open multiple dates. This database example application </span></div>
<div class=ts61p56><span class="ft7p61">opens one window for each day. If the user opens two (or more) days and moves an </span></div>
<div class=ts61p57><span class="ft7p61">appointment from one day to the other, there is a problem at save time. If you choose to </span></div>
<div class=ts61p59><span class="ft7p61">merely loop through the appointments and save those appointments that have their </span></div>
<div class=ts61p60><span class="ft7p61">&#147;IsDirty&#148; property set to true, you will add an extra appointment each time you move </span></div>
<div class=ts61p61><span class="ft7p61">across windows. This is because the source schedule will lose an appointment and </span></div>
<div class=ts61p63><span class="ft7p61">since no appointments on the schedule have changed, you save nothing. The </span></div>
<div class=ts61p64><span class="ft7p61">destination schedule has one new appointment, so you save it. Now think about it, the </span></div>
<div class=ts61p65><span class="ft7p61">source date still has the moved appointment in the database. Now you save the same </span></div>
<div class=ts61p67><span class="ft7p61">appointment with the destination date. You have one more appointment than the </span></div>
<div class=ts61p68><span class="ft7p61">number with which you started. You may use the appointment&#146;s UniqueKey property to </span></div>
<div class=ts61p69><span class="ft7p61">overcome this limitation, but this is beyond the current scope. </span></div>
<div class=ts61p72><span class="ft7p61"> </span></div>
<div class=ts61p73><span class="ft5p61">Public Sub SaveSchedule() </span></div>
<div class=ts61p75><span class="ft5p61"> </span></div>
<div class=ts61p76><span class="ft5p61">'This procedure saves a schedule to the database </span></div>
<div class=ts61p78><span class="ft5p61"> </span></div>
<div class=ts61p79><span class="ft5p61">Dim Db As ADODB.Connection </span></div>
<div class=ts61p81><span class="ft5p61">Dim sSql As String </span></div>
<div class=ts61p83><span class="ft5p61">Dim lCategoryId As Long </span></div>
<div class=styleNavBarBot>
<table width="836" border="0" cellspacing="2">
  <tr></tr>
  <tr>
    <td width="118"><a href="http://www.purepage.com"><img src="./smalllogo.gif" width="118" height="46" border="0" alt="http://www.purepage.com"></a></td>
    <td></td>
  </tr>
</table>
</div>

</td></tr></table>

</body>
</html>
